

#import "FocusDoctorController.h"
#import "QcFocusCell.h"
#import "QcDoctorInfoController.h"
#import "NetWorkTool.h"
#import "QcDoctorApplyModel.h"

@interface FocusDoctorController ()<UITableViewDelegate,UITableViewDataSource>

@property (nonatomic, strong) UITableView *tableview;

@property (nonatomic, strong) NSArray <QcDoctorApplyModel *>*AppModelList;

@end

static NSString *foucusCell = @"aa";
@implementation FocusDoctorController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self loadData];
    
    [self setupUI];
    
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(iszan :) name:@"zan" object:nil];
}



- (void)iszan:(NSNotification *)noti{
    
    NSIndexPath* indexPath = [self.tableview indexPathForSelectedRow];
    
    self.AppModelList[indexPath.row].selected = noti.object;
    
 //   NSLog(@"%@",self.AppModelList[indexPath.row].selected);
    
  //  NSLog(@"noti.obj%@",noti.object);
    
    [self.tableview reloadData];
}



-(void)loadData {
    
        NSDictionary *dict = @{@"ci1_id":@1,@"ci2_id":@3,@"ci3_id":@3,@"diagnosis_type":@0,@"page_size":@15,@"is_confirmed":@1,@"user_id":@1000089, @"page":@1,@"has_diagnosis":@2};
    
    [[NetWorkTool shareManager] POST_RequestWithUrlString:kMatchDoctors parmas:dict successBloock:^(id responseObject) {
        
        NSArray *array = responseObject[@"data"];
        
        self.AppModelList = [NSArray yy_modelArrayWithClass:[QcDoctorApplyModel class] json:array];
        
        
        [self.tableview reloadData];
        
        
    } failureBlock:^(NSError *error) {
        
    }];
}
- (void)setupUI {
    
    UITableView *tableView = [[UITableView alloc]init];
    
    tableView.rowHeight = UITableViewAutomaticDimension;
    tableView.estimatedRowHeight = 100;
    
    self.tableview = tableView;
    
    tableView.delegate = self;
    
    tableView.dataSource = self;
    
    [self.view addSubview:tableView];
    
    [tableView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.edges.equalTo(self.view);
        
    }];
    
    [tableView registerNib:[UINib nibWithNibName:@"QcFocusCell" bundle:nil] forCellReuseIdentifier:foucusCell];
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return 10;
}


-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    QcFocusCell *cell =[tableView dequeueReusableCellWithIdentifier:foucusCell forIndexPath:indexPath];
    
    QcDoctorApplyModel *model = self.AppModelList[indexPath.row];
    
    cell.appModel = model;

    cell.selected = self.AppModelList[indexPath.row].selected;
    
    return cell;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    
    QcDoctorInfoController *infoView = [QcDoctorInfoController new];
    
    infoView.ApplyModel = self.AppModelList[indexPath.row];
    
    infoView.selected = [(self.AppModelList[indexPath.row].selected)integerValue];
    
    //NSLog(@"dianji%@",self.AppModelList[indexPath.row].selected);
    
  //  NSLog(@"infoView点击传值%d",infoView.selected);
    
    [self.navigationController pushViewController:infoView animated:YES];
    
}


@end
